#include"StackTest.h"


bool isvalid(char** s)
{
	ST st;
	STInit(&st);
	char TopVal;
	while (**s)
	{
		if (**s == '{' || **s == '[' || **s == '(')
		{
			STPush(&st,**s);
		}
		else
		{
			if (STEmpty(&st))
			{
				STDestroy(&st);
				return false;
			}
			TopVal = STTop(&st);
			STPop(&st);
			if (**s == '}' && TopVal != '{' || **s == ']' && TopVal != '[' || **s == ')' && TopVal != '(')
			{
				STDestroy(&st);
				return false;
			}
		}
		++*s;
	}
	bool ret = STEmpty(&st);
	STDestroy(&st);
	return ret;
}

int main()
{
	char *p = "{[()]}";
	bool ret1=1;
	ret1=isvalid(&p);
	printf("%d\n", ret1);
	return 0;
}